/**
 * @(#) ProfileProxy.as
 *
 * @date		2009. 02. 12.
 * @version		1.0
 * @author		Shin, Yunwoo
 * @description	 인사기록 조회 - Proxy
 * 				인사기록을 조회하는 Model Logic 
 */
package com.skt.common_hr.main.model
{
	import com.skt.common_hr.common.puremvc.CommonProxy;
	
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;

	public class MyApprovalProxy extends CommonProxy
	{
		public static const NAME:String = "MyApprovalProxy";
		
		static public const LOAD_MYAPPROVAL_COMPLETE:String	= "loadMyApprovalComplete";
		static public const LOAD_MYAPPROVAL_FAILED:String		= "loadMyApprovalFailed";
		
		public var WNUM:Number = 0;
		public var SNUM:Number = 0;
		public var BNUM:Number = 0;
		
		/**
		 * 생성자
		 * 
		 * @param
		 * @return void
		 */
		public function MyApprovalProxy(data:Object=null)
		{
			super(NAME, data);
		}
		
		
		/**
		 * data load를 수행
		 * 		- DataLoader 를 생성하고 Import Parameter 객체를 생성, RFC를 호출
		 * 
		 * @param pernr 사번
		 * @return void
		 */
		public function load(pernr:String):void
		{
			var param:Object = new Object();
			param["I_PERNR"] = pernr;
			loadData("Z_HR_0106", param, result, fault); 
		}
		
		
		
		
		
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Event Listeners
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		 * 서버에서 정상적으로 리턴된 결과를 처리
		 * 
		 * @param
		 * @return void
		 */
		public function result(event:ResultEvent):void
		{
			if(retCode==0) {  
				WNUM = event.result["O_WNUM"];
				SNUM = event.result["O_SNUM"];
				BNUM = event.result["O_BSUM"];
				facade.sendNotification(LOAD_MYAPPROVAL_COMPLETE, this);
			}
			else {
				facade.sendNotification(LOAD_MYAPPROVAL_FAILED, this);
			}
		}
		
		/**
		 * 서버에서 오류가 발생했을 처리
		 * 
		 * @param
		 * @return void
		 */
		private function fault(event:FaultEvent):void
		{
			facade.sendNotification(LOAD_MYAPPROVAL_FAILED, this);
		}
		
		
		
		
		
	}
}